package edu.hunan.cxb18.controller;

import edu.hunan.cxb18.pojo.Category;
import edu.hunan.cxb18.result.CommonTypeResult;
import edu.hunan.cxb18.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author AuthorName
 * @create 2020-04-25 20:24
 */
@CrossOrigin
@RestController
@RequestMapping("/category")
public class CategoryController {
    @Autowired
    private CategoryService categoryService;
    @GetMapping("/toplevel")
    public CommonTypeResult toplevel(){
        List<Category> topleveCategory = categoryService.findTopleveCategory();
        return CommonTypeResult.creat(topleveCategory);
    }
}
